<?php
require("include/top.php");

if(isset($_POST['save'])) {

	require(FORM_PATH."add_sharing.form.php");
}

if(isset($_GET['id'])) {
	$rsharing=new Sharing($_GET['id']);
	$rsharing->load();
	$tpl->assign('rsharing',$rsharing);
}

$sharings=Sharing::getSharings();
$tpl->assign('sharings',$sharings);

if((isset($rsharing['vendor']['id']))&&(isset($_POST['save']))) {
	header('Location:add_commercant.php?id='.$rsharing['vendor']['id'].'');
}
elseif((!isset($rsharing['vendor']['id']))&&(isset($_POST['save']))){
	header('Location:add_sharing.php?id='.$rsharing['id'].'');
}

$tpl->display("header.tpl");
$tpl->display("menu.tpl");
$tpl->display("add_sharing.tpl");
$tpl->display("footer.tpl");

require("include/bottom.php");	

?>